package property.personal.property_mange.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class ImageConfig implements WebMvcConfigurer {

    @Value("${upload.dir}")
    private String upload;

    @Value("${upload.tmp.dir}")
    private String tmp ;

//    @Value("${kefu.upload.dir}")
//    private String kefuUpload;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        String os = System.getProperty("os.name");
        registry.addResourceHandler("/upload/**").addResourceLocations("file:" + upload);
//        registry.addResourceHandler("/kefuUpload/**").addResourceLocations("file:" + kefuUpload);
        registry.addResourceHandler("/screen/**").addResourceLocations("file:" + upload + "screen/");
        registry.addResourceHandler("/video/**").addResourceLocations("file:" + upload + "video/");
        registry.addResourceHandler("/images/**").addResourceLocations("file:" + upload + "images/");
        registry.addResourceHandler("/banners/**").addResourceLocations("file:" + upload + "images/banners");
        // 临时目录添加访问映射
        registry.addResourceHandler("/upload/**").addResourceLocations("file:" + tmp);
//        registry.addResourceHandler("/temp-rainy/**").addResourceLocations("file:D:/temp-rainy/");
    }
}
